import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 店面信息信息 */
export interface StoreInfo {
          storeName?: string; // 店面名称
          cityId?: number; // 所属城市ID
          address?: string; // 详细地址
          imageUrl?: string; // 店面图片URL
          contactPerson: string; // 联系人
          phone?: string; // 联系电话
          businessHours?: string; // 营业时间(如:09:00-21:00)
          isActive?: boolean; // 是否营业(1=营业,0=关闭)
}

/** 城市信息信息 */
export interface City {
          province?: string; // 省份
          cityName?: string; // 城市名称
          adCode: string; // 行政区划代码
          isActive?: number; // 是否启用(1=启用,0=禁用)
  }

// 城市信息 API
export const CityApi = {
  // 查询城市信息分页
  getCityPage: async (params: any) => {
    return await request.get({ url: `/recycling/city/page`, params })
  },

  // 查询城市信息详情
  getCity: async (id: number) => {
    return await request.get({ url: `/recycling/city/get?id=` + id })
  },

  // 新增城市信息
  createCity: async (data: City) => {
    return await request.post({ url: `/recycling/city/create`, data })
  },

  // 修改城市信息
  updateCity: async (data: City) => {
    return await request.put({ url: `/recycling/city/update`, data })
  },

  // 删除城市信息
  deleteCity: async (id: number) => {
    return await request.delete({ url: `/recycling/city/delete?id=` + id })
  },

  /** 批量删除城市信息 */
  deleteCityList: async (ids: number[]) => {
    return await request.delete({ url: `/recycling/city/delete-list?ids=${ids.join(',')}` })
  },

  // 导出城市信息 Excel
  exportCity: async (params) => {
    return await request.download({ url: `/recycling/city/export-excel`, params })
  },

// ==================== 子表（店面信息） ====================

  // 获得店面信息分页
  getStoreInfoPage: async (params) => {
    return await request.get({ url: `/recycling/city/store-info/page`, params })
  },
  // 新增店面信息
  createStoreInfo: async (data: StoreInfo) => {
    return await request.post({ url: `/recycling/city/store-info/create`, data })
  },

  // 修改店面信息
  updateStoreInfo: async (data: StoreInfo) => {
    return await request.put({ url: `/recycling/city/store-info/update`, data })
  },

  // 删除店面信息
  deleteStoreInfo: async (id: number) => {
    return await request.delete({ url: `/recycling/city/store-info/delete?id=` + id })
  },

  /** 批量删除店面信息 */
  deleteStoreInfoList: async (ids: number[]) => {
    return await request.delete({ url: `/recycling/city/store-info/delete-list?ids=${ids.join(',')}` })
  },

  // 获得店面信息
  getStoreInfo: async (id: number) => {
    return await request.get({ url: `/recycling/city/store-info/get?id=` + id })
  },
}